package org.jeecg.modules.job.bms.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.job.bms.entity.BmsCity;
import org.jeecg.modules.job.bms.mapper.BmsCityMapper;
import org.jeecg.modules.job.bms.service.IBmsCityService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 城市信息
 * @Author: jeecg-boot
 * @Date:   2022-10-27
 * @Version: V1.0
 */
@Service
public class BmsCityServiceImpl extends ServiceImpl<BmsCityMapper, BmsCity> implements IBmsCityService {

    @Resource
    private BmsCityMapper cityMapper;

    @Override
    public IPage<BmsCity> getCityPageList(Page<BmsCity> page, BmsCity params) {
        return cityMapper.getCityPageList(page,params);
    }

    @Override
    public List<Map<String, Object>> getCityMapList(BmsCity params) {
        return cityMapper.getCityMapList(params);
    }

    @Override
    public Map<String, Object> findListForApp(BmsCity param) {
        String[] alphabet={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
        Map<String,Object> result=new HashMap<>();
        result.put("alphabet",alphabet);
        Map<String,Object> citys=new HashMap<>();
        List<Map<String,Object>> cityResults;
        for (String str:alphabet){
            param.setIndexLetter(str);
            cityResults=this.baseMapper.getCityMapList(param);
            citys.put(str,cityResults);
        }
        result.put("citys",citys);
        List<Map<String,Object>> hot=this.baseMapper.getCityMapList(new BmsCity().setIfHot(1));
        result.put("hotcity",hot);
        //热门城市
        return result;
    }
}
